//
//  WFAboutUsViewController.m
//  FAKER
//
//  Created by Jianwei on 15/11/16.
//  Copyright © 2015年 YHLai. All rights reserved.
//

#import "WFAboutUsViewController.h"
#import "WFWeiboViewController.h"
#import "AllHeader.h"
#import "FitHeader.h"
#define WFUrlString @"http://weibo.com/u/5290447258"
#define LQYUrlString @"http://weibo.com/u/3260358984"
#define LYHUrlString @"http://weibo.com/u/3861373848"
@interface WFAboutUsViewController ()
@property(nonatomic, strong)UILabel *WFLabel;
@property(nonatomic, strong)UILabel *LYHLabel;
@property(nonatomic, strong)UILabel *LQYLabel;
@property(nonatomic, strong)NSArray *urlArray;
@property(nonatomic, strong)BaseClassImageView *logoImageView;
@property(nonatomic, strong)UILabel *brandNameLabel;
@property(nonatomic, strong)UILabel *contentLabel;
@property(nonatomic, strong)UILabel *contactLabel;
@property(nonatomic, strong)UIView *spacingView;
@property(nonatomic, strong)UIView *borderView;
@end

@implementation WFAboutUsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"关于我们";
    
    [self changeColor];
}

- (void)changeColor
{
    if (NSUSERDEFAULTS_NIGHT) {
        self.navigationController.navigationBar.tintColor = [UIColor lightGrayColor];
        _brandNameLabel.textColor = [UIColor lightGrayColor];
        _contentLabel.textColor = [UIColor lightGrayColor];
        _spacingView.backgroundColor = [UIColor darkGrayColor];
        _borderView.layer.borderColor = [UIColor darkGrayColor].CGColor;
    } else {
        self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
//        _brandNameLabel.textColor = [UIColor grayColor];
        _contentLabel.textColor = [UIColor darkGrayColor];
        _spacingView.backgroundColor = [UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:1];
        _borderView.layer.borderColor = [UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:1].CGColor;
    }
}

- (void)viewWillDisappear:(BOOL)animated
{
//    self.navigationController.navigationBar.hidden = 0;
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
}
- (void)pushViewController:(UITapGestureRecognizer *)tap
{
        WFWeiboViewController *wc = [[WFWeiboViewController alloc]initWithURL:[NSURL URLWithString:_urlArray[tap.view.tag - 1000]]];
        [wc setHidesBottomBarWhenPushed:1];
        [self.navigationController pushViewController:wc animated:1];
}
- (void)loadView
{
    [super loadView];
    
    _logoImageView = [[BaseClassImageView alloc] initWithFrame:CGRectMake(0, 30 * FITHEIGHT, 50 * FITWIDTH, 50 * FITWIDTH)];
    _logoImageView.center = CGPointMake(self.view.center.x, _logoImageView.center.y);
    _logoImageView.image = [UIImage imageNamed:@"F"];
    _logoImageView.layer.cornerRadius = 10;
    [self.view addSubview:_logoImageView];
    
    _brandNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, _logoImageView.Y + _logoImageView.HEIGHT, SCREEN_WIDTH, 30 * FITHEIGHT)];
    _brandNameLabel.textAlignment = NSTextAlignmentCenter;
    _brandNameLabel.text = @"FAKER";
    _brandNameLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:17];
    [self.view addSubview:_brandNameLabel];
    
    NSString *contentString = @"FAKER是一款个性化新闻阅读软件, 艳丽的色彩搭配和极其简洁的阅读界面, 带来前所未有的视觉享受!\n\n每3个人就有1个人在了解天下资讯\n每1秒钟就有100万+人与你同时阅读新鲜头条\n你还在等什么? 快快加入FAKER吧!";
    CGFloat contentHeight = [Adaptive AdaptiveHeightByString:contentString Width:SCREEN_WIDTH - 60 * FITWIDTH FontSize:15];
    _contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(30 * FITWIDTH, _brandNameLabel.Y + _brandNameLabel.HEIGHT + 10 * FITHEIGHT, SCREEN_WIDTH - 60 * FITWIDTH, contentHeight)];
    _contentLabel.text = contentString;
    _contentLabel.numberOfLines = 0;
    _contentLabel.font = [UIFont systemFontOfSize:15];
    [self.view addSubview:_contentLabel];
    
    _spacingView = [[UIView alloc] initWithFrame:CGRectMake(0, _contentLabel.Y + _contentLabel.HEIGHT + 30 * FITHEIGHT, SCREEN_WIDTH, 10 * FITHEIGHT)];
    [self.view addSubview:_spacingView];
    
    _contactLabel = [[UILabel alloc] initWithFrame:CGRectMake(_contentLabel.X, _spacingView.Y + _spacingView.HEIGHT + 30 * FITHEIGHT, 200 * FITWIDTH, 30 * FITHEIGHT)];
//    _contactLabel.frame = CGRectMake(_contentLabel.X, _contentLabel.Y + _contentLabel.HEIGHT + 30, 100, 30);
    _contactLabel.textColor = [[UIButton buttonWithType:UIButtonTypeSystem] titleColorForState:UIControlStateNormal];
    _contactLabel.text = @"我们的联系方式";
    _contactLabel.font = [UIFont systemFontOfSize:15];
    _contactLabel.textColor = [UIColor colorWithRed:0.44 green:0.75 blue:1 alpha:1];
    [self.view addSubview:_contactLabel];
    
    _borderView = [[UIView alloc] initWithFrame:CGRectMake(_contactLabel.X, _contactLabel.Y + _contactLabel.HEIGHT + 10 * FITHEIGHT, SCREEN_WIDTH - 60 * FITWIDTH, 120 * FITHEIGHT)];
    _borderView.layer.borderWidth = 1.5;
    _borderView.layer.cornerRadius = 10;
    [self.view addSubview:_borderView];
    
    [self createOurContact];
}

- (void)createOurContact
{
    _urlArray = @[WFUrlString, LYHUrlString, LQYUrlString];
    NSArray *nameArray = @[@"王健伟_sir", @"LAIYIHANG", @"兰桑_Blue"];
    NSMutableArray *labelArray = [NSMutableArray array];
    
    for (NSInteger i = 0; i < 3; i++) {
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(_contactLabel.X + 30 * FITWIDTH, _contactLabel.Y + _contactLabel.HEIGHT + 10 * FITHEIGHT + 40 * FITHEIGHT * i, _borderView.WIDTH, 40 * FITHEIGHT)];
        label.userInteractionEnabled = 2;
        label.tag = 1000 + i;
        if (NSUSERDEFAULTS_NIGHT) {
            label.textColor = [UIColor lightGrayColor];
        } else {
            label.textColor = [UIColor darkGrayColor];
        }
        label.textAlignment = NSTextAlignmentLeft;
        label.font = [UIFont systemFontOfSize:15];
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(pushViewController:)];
        [label addGestureRecognizer:tap];
        label.text = nameArray[i];
        [labelArray addObject:label];
        
        if (i != 0) {
            UIView *spacingLineView = [[UIView alloc] initWithFrame:CGRectMake(_borderView.X, _borderView.Y + 40 * FITHEIGHT * i, _borderView.WIDTH, 1.5)];
            if (NSUSERDEFAULTS_NIGHT) {
                spacingLineView.backgroundColor = [UIColor darkGrayColor];
            } else {
                spacingLineView.backgroundColor = [UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:1];
            }
            [self.view addSubview:spacingLineView];
        }
    }
    _WFLabel = labelArray[0];
    _LYHLabel = labelArray[1];
    _LQYLabel = labelArray[2];
    
    [self.view addSubview:_WFLabel];
    [self.view addSubview:_LYHLabel];
    [self.view addSubview:_LQYLabel];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
